#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;




template<class T>
class sequence
{
public:
	void Insert(const T& val)
	{
		if (v.size() == 0)
		{
			v.push_back(val);
		}
		else
		{
			auto it = v.begin();
			while (it!=v.end())
			{
				if (val <= *it)
				{
					v.insert(it, val);
					break;
				}
				else
				{
					it++;
				}
			}
			if (val>v.back())
			{
				v.push_back(val);
			}
		}
	}

	void Reverse(typename std::vector<T>::iterator Begin, typename std::vector<T>::iterator End)
	{
		while (Begin < End)
		{
			std::swap(*Begin, *(--End));
			++Begin;
		}
	}

	void rotate(int k)
	{
		k = k % v.size();
		Reverse(v.begin(), v.end());
		Reverse(v.begin(), (v.begin() + (k)));
		Reverse((v.begin() + (k)), v.end());
	}



	/*void sort()
	{
		std::sort(v.begin(), v.end());
	}*/

	void Print()
	{
		for (auto& e : v)
		{
			cout << e << " ";
		}
		cout << endl;
	}

private:
	vector<T> v;
};

